package cn.novate.jetpackdemo.workmanager;

import android.content.Context;
import android.util.Log;

import androidx.annotation.NonNull;
import androidx.work.Worker;
import androidx.work.WorkerParameters;

/**
 * 简单任务
 */
public class UploadWorker extends Worker {

    private final static String TAG = UploadWorker.class.getCanonicalName();

    public UploadWorker(@NonNull Context context, @NonNull WorkerParameters workerParams) {
        super(context, workerParams);
    }

    //  后台任务   并且异步
    @NonNull
    @Override
    public Result doWork() {

        try {
            Thread.sleep(6000);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }finally {
            Log.e(TAG,"doWork：  开始执行了。。。。。");
        }

        return Result.success();//  本次任务成功
    }
}
